package com.zscg.sequence.ui.view;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public abstract class BaseListAdapter extends BaseAdapter {

	protected BaseListView listView;

	protected LayoutInflater mInflater;

	protected boolean isMore;

	public BaseListAdapter(Context context) {
		mInflater = LayoutInflater.from(context);
		isMore = true;
	}

	public abstract View inflateItemView(int position, ViewGroup parent);

	public abstract Object getItemViewHolder(View convertView);

	public abstract void fillViewHolder(int position, Object viewHolder,
			ViewGroup parent);

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Object viewholder = null;
		if (convertView == null) {
			convertView = inflateItemView(position, parent);
			viewholder = getItemViewHolder(convertView);
			convertView.setTag(viewholder);
		} else {
			viewholder = convertView.getTag();
		}
		try {
			fillViewHolder(position, viewholder, parent);
		} catch (Exception e) {
		}
		return convertView;
	}

	void baseLoadMore() {
		this.loadMore();
	}

	protected abstract void loadMore();

	protected boolean isMore() {
		return isMore;
	}

}
